<?php
$aBreadcrumbs = array();
?>

<div class="goods list">

	<div class="sort">
        <?php
        $url = (!empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');
        $url = preg_replace('`&?s=[a-z]+`i', '', $url);
        $url = preg_replace('`&?page=\d+`i', '', $url);
        $url = '?'.($url ? $url.'&s=' : 's=');
        ?>
		<span><?php echo _('Сортировать по:'); ?></span>
		<a rel="nofollow" <?php echo $sortBy === 'newest' ? ' class="selected"' : ''; ?> href="<?php echo $url.'newest'; ?>"><?php echo _('новинкам'); ?></a>
		<a rel="nofollow" <?php echo $sortBy === 'popularity' ? ' class="selected"' : ''; ?> href="<?php echo $url.'popularity'; ?>"><?php echo _('популярности'); ?></a>
		<a rel="nofollow" <?php echo $sortBy === 'name' ? ' class="selected"' : ''; ?> href="<?php echo $url.'name'; ?>"><?php echo _('имени'); ?></a>
		<a rel="nofollow" <?php echo $sortBy === 'low' ? ' class="selected"' : ''; ?> href="<?php echo $url.'low'; ?>"><?php echo _('наименьшей цене'); ?></a>
		<a rel="nofollow" <?php echo $sortBy === 'high' ? ' class="selected"' : ''; ?> href="<?php echo $url.'high'; ?>"><?php echo _('наибольшей цене'); ?></a>
		<a rel="nofollow" <?php echo $sortBy === 'off' ? ' class="selected"' : ''; ?> href="<?php echo $url.'off'; ?>"><?php echo _('% скидки'); ?></a>
	</div>

    <?php if($oRowset): ?>
	<div class="list">
        <?php foreach($oRowset as $oRow): ?><a href="<?php echo $this->createUrl('/goods/default/view/', array('id' => $oRow->alias, 'category' => $oRow->category_alias)); ?>">
            <?php if($oRow->getPhoto()): ?>
            <figure>
                <img class="lazy" alt="<?php echo $oRow->title; ?>" title="<?php echo $oRow->title; ?>" data-original="<?php echo $this->widget('ext.Img', array(
                    'oRow' => $oRow->getPhoto(),
                    'size' => 'list'
                )); ?>" />
                <img class="loader" src="/img/ajax-loader.gif" />
            </figure>
            <?php endif; ?>

            <div class="title"><?php echo $oRow->title; ?></div>
            <p class="price"><?php echo Currencies::convert($oRow->price); ?></p>
	        <?php if($oRow->old_price > 0): ?>
            <p class="was"><span><?php echo Currencies::convert($oRow->old_price); ?></span> <span>скидка <?php echo 100 - round($oRow->price / $oRow->old_price * 100) ?>%</span></p>
			<?php endif; ?>
        </a><?php endforeach; ?>
	</div>
    <?php endif; ?>


    <?php
    $this->widget('CLinkPager', array(
        'pages' => $this->oPager,
        'maxButtonCount'=>5,
        'header'=>'',
        'htmlOptions'=>array('class'=>'pager'),
    )); ?>

</div>
